import useModal from '@/hooks/modalHook'

const AddDevModal = defineComponent({
  props: {
    visible: Boolean
  },
  emits: {
    'update:visible': Boolean
  },
  setup(props, ctx) {
    const {openModal, closeModal, visible} = useModal()

    watch(
      () => props.visible,
      n => {
        if (n) {
          openModal()
        } else {
          closeModal()
        }
      },
      {immediate: true}
    )

    return () => <a-modal v-model={[visible.value, 'visible']} title='添加设备'></a-modal>
  }
})

export default AddDevModal
